<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <h:form id="AlertsListForm"> 

        <p:panel header="#{MyBundle.ListAlertsTitle}">
            <p:contextMenu for="datalist">  

                <p:menuitem id="readMenuItem" icon="ui-icon-search" value="#{MyBundle.View}" onclick="document.getElementById('AlertsListForm:viewButton').click();"/>
                
                <p:menuitem disabled="true" id="createMenuItem" icon="ui-icon-plus" value="#{MyBundle.Create}" onclick="document.getElementById('AlertsListForm:createButton').click();"/>
                <p:menuitem disabled="true" id="updateMenuItem" icon="ui-icon-pencil" value="#{MyBundle.Edit}" onclick="document.getElementById('AlertsListForm:editButton').click();"/>
                <p:menuitem disabled="true" id="deleteMenuItem" icon="ui-icon-trash" value="#{MyBundle.Delete}" onclick="document.getElementById('AlertsListForm:deleteButton').click();"/>
                
            </p:contextMenu>
            <p:dataTable id="datalist"
                         value="#{alertsController.items}"
                         var="item"
                         rowKey="#{item.id}"
                         paginator="true"
                         rows="10"
                         rowsPerPageTemplate="10,20,30,40,50"
                         selectionMode="single"
                         selection="#{alertsController.selected}">

                <p:ajax event="rowSelect"   update=":AlertsListForm:createButton :AlertsListForm:viewButton :AlertsListForm:editButton :AlertsListForm:deleteButton"/>
                <p:ajax event="rowUnselect" update=":AlertsListForm:createButton :AlertsListForm:viewButton :AlertsListForm:editButton :AlertsListForm:deleteButton"/>
                <p:ajax event="rowDblselect" onsuccess="document.getElementById('AlertsListForm:viewButton').click();"/>

                <!--
                <p:column sortBy="#{item.id}" filterBy="#{item.id}">
                    <f:facet name="header">
                        <h:outputText value="#{MyBundle.ListAlertsTitle_id}"/>
                    </f:facet>
                    <h:outputText value="#{item.id}"/>
                </p:column>
                -->

                <p:column sortBy="#{item.type}" filterBy="#{item.type}">
                    <f:facet name="header">
                        <h:outputText value="#{MyBundle.ListAlertsTitle_type}"/>
                    </f:facet>
                    <h:outputText value="#{item.type}"/>
                </p:column>

                <!--
                <p:column sortBy="#{item.latitude}" filterBy="#{item.latitude}">
                    <f:facet name="header">
                        <h:outputText value="#{MyBundle.ListAlertsTitle_latitude}"/>
                    </f:facet>
                    <h:outputText value="#{item.latitude}"/>
                </p:column>

                <p:column sortBy="#{item.longitude}" filterBy="#{item.longitude}">
                    <f:facet name="header">
                        <h:outputText value="#{MyBundle.ListAlertsTitle_longitude}"/>
                    </f:facet>
                    <h:outputText value="#{item.longitude}"/>
                </p:column>

                -->
                <p:column sortBy="#{item.description}" filterBy="#{item.description}">
                    <f:facet name="header">
                        <h:outputText value="#{MyBundle.ListAlertsTitle_description}"/>
                    </f:facet>
                    <h:outputText value="#{item.description}"/>
                </p:column>


                <p:column sortBy="#{item.phone}" filterBy="#{item.phone}">
                    <f:facet name="header">
                        <h:outputText value="#{MyBundle.ListAlertsTitle_phone}"/>
                    </f:facet>
                    <h:outputText value="#{item.phone}"/>
                </p:column>


                <p:column sortBy="#{item.name}" filterBy="#{item.name}">
                    <f:facet name="header">
                        <h:outputText value="#{MyBundle.ListAlertsTitle_name}"/>
                    </f:facet>
                    <h:outputText value="#{item.name}"/>
                </p:column>

                <p:column sortBy="#{item.date}" filterBy="#{item.date}">
                    <f:facet name="header">
                        <h:outputText value="#{MyBundle.ListAlertsTitle_date}"/>
                    </f:facet>
                    <h:outputText value="#{item.date}">
                        <f:convertDateTime pattern="MM/dd/yyyy HH:mm:ss" />
                    </h:outputText>
                </p:column>

                <p:column sortBy="#{item.user.user}" filterBy="#{item.user.user}">
                    <f:facet name="header">
                        <h:outputText value="#{MyBundle.ListAlertsTitle_user}"/>
                    </f:facet>
                    <h:outputText value="#{item.user.user}"/>
                </p:column>

            </p:dataTable>


            <p:commandButton id="viewButton"   style="visibility: hidden;" icon="ui-icon-search" value="#{MyBundle.View}" update=":AlertsViewForm" oncomplete="AlertsViewDialog.show()" disabled="#{empty alertsController.selected}"/>
            
            <p:commandButton   id="createButton"                            icon="ui-icon-plus"   value="#{MyBundle.Create}" actionListener="#{alertsController.prepareCreate}" update=":AlertsCreateForm" oncomplete="AlertsCreateDialog.show()"/>
            <p:commandButton   id="editButton"   style="visibility: hidden;" icon="ui-icon-pencil" value="#{MyBundle.Edit}" update=":AlertsEditForm" oncomplete="AlertsEditDialog.show()" disabled="#{empty alertsController.selected}"/>
            <p:commandButton   id="deleteButton" style="visibility: hidden;" icon="ui-icon-trash"  value="#{MyBundle.Delete}" actionListener="#{alertsController.delete}" update=":growl,datalist" disabled="#{empty alertsController.selected}">
                <p:confirm header="#{MyBundle.ConfirmationHeader}" message="#{MyBundle.ConfirmDeleteMessage}" icon="ui-icon-alert"/>
            </p:commandButton>
           
        </p:panel>
        <ui:include src="/WEB-INF/include/confirmation.xhtml"/>
    </h:form>

</ui:composition>